{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-08-21T03:43:54.367652Z",
     "start_time": "2020-08-21T03:43:54.352681Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********************************************************************\n",
      "File \"__main__\", line 4, in __main__.average\n",
      "Failed example:\n",
      "    print(average([20, 30, 70]))\n",
      "Expected nothing\n",
      "Got:\n",
      "    40.0\n",
      "**********************************************************************\n",
      "File \"__main__\", line 6, in __main__.average\n",
      "Failed example:\n",
      "    print(\"hello anlzou, this is auto test module.\")\n",
      "Expected nothing\n",
      "Got:\n",
      "    hello anlzou, this is auto test module.\n",
      "**********************************************************************\n",
      "1 items had failures:\n",
      "   2 of   2 in __main__.average\n",
      "***Test Failed*** 2 failures.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "TestResults(failed=2, attempted=2)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def average(values):\n",
    "    \"\"\"\n",
    "    自动测试输出的内容\n",
    "    >>> print(average([20, 30, 70]))\n",
    "    \n",
    "    >>> print(\"hello anlzou, this is auto test module.\")\n",
    "    \"\"\"\n",
    "    return sum(values) / len(values)\n",
    "import doctest\n",
    "doctest.testmod()   # 自动验证嵌入测试"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "举例：在VBScript中，可以将字符串 '12' 和整数 3 进行连接得到字符串 '123'，  然后可以把它看成整数 123，而不需要显示转换\n",
    "\n",
    "例如PHP/ASP/Ruby/~~Python~~/Perl/ABAP/SQL/JavaScript/Unix Shell等"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-08-30T02:44:38.294936Z",
     "start_time": "2020-08-30T02:44:38.288404Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "15\n",
      "123\n"
     ]
    }
   ],
   "source": [
    "str_ = '12'\n",
    "print(int(str_) + 3)\n",
    "print(int(str_ + str(3)))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
